package com.fotoaf;

import java.io.File;

import android.app.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.Toast;


public class principal extends Activity {
    /** Called when the activity is first created. */

	private String sitios[]={"HTOL0041","HTOL0052","HTOL0063"};
	private String nombres[]={"SECTOR 58","SECTOR 59","SECTOR 60"};
	private Spinner lstSitio;
	private Spinner lstNombres;
	public static String  catalogo="test";
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        lstSitio=(Spinner) findViewById(R.id.lstSitio);
        lstNombres=(Spinner) findViewById(R.id.lstNombres);
        ArrayAdapter<String> adpSitios = new ArrayAdapter<String>(this,
        		android.R.layout.simple_spinner_item,sitios);
        ArrayAdapter<String> adpNombres = new ArrayAdapter<String>(this,
        		android.R.layout.simple_spinner_item,nombres);        
        adpSitios.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        adpNombres.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);        
        lstSitio.setAdapter(adpSitios);
        lstNombres.setAdapter(adpNombres);
        
        Button btnSig=(Button) findViewById(R.id.button1);
        btnSig.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				
				catalogo=lstSitio.getSelectedItem().toString()+"_"+lstNombres.getSelectedItem().toString();				
				//Environment.getExternalStorageDirectory().getAbsolutePath() +
				File path = new	File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/fotoAF/");	            
				if(!path.exists()) 
					if(path.mkdir()) 
						Toast.makeText(principal.this,"En "+path.getPath(), Toast.LENGTH_SHORT).show();
					else
						Toast.makeText(principal.this,"Fallo al crear /fotoAF/", Toast.LENGTH_SHORT).show();
				
				Intent about=new Intent(principal.this,tomafoto.class );
				startActivity(about);
			}
		});
    }
}